{extend name="layout" /}
{block name="content"}
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class="layui-this">{$pathCurrent['name']}</li>
    </ul>
</div>
<div class="layui-card-body">
    <div data-model="table-bind">
        <table class="layui-hide" id="data_table" lay-filter="data_table" data-table></table>
    </div>
</div>
<script type="text/html" id="barTar">
    <a class="layui-btn layui-btn-xs" href="{{d.op}}">编辑</a>
</script>
<script type="text/html" id="headimgurl">
    <img src="{{d.headimgurl}}" width="30" height="30">
</script>
<script type="text/html" id="image">
    <img src="{{d.image}}" height="30">
</script>
<script type="text/html" id="sysTar">
    {{#  if(d.status == 1){ }}
    <button type="button" class="layui-btn layui-btn-normal">正常</button>
    {{#  } else { }}
    <button type="button" class="layui-btn layui-btn-danger">关闭</button>
    {{#  } }}
</script>
{/block}
{block name="js"}
<script type="text/javascript">
    var mixin = {};
    var SlefUrl = this.location.href;
    layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#data_table',
            url:SlefUrl,
            limit:20,
            cellMinWidth: 80,
            cols: [[
                {field:'headimgurl',width:80, title: '头像',toolbar: '#headimgurl', align:'center'},
                {field:'name', title: '代理姓名', sort: true,align:'left'},
                {field:'goods_name', title: '商品名称', width:180, sort: true,align:'left'}
                ,{field:'num', title: '商品数量', sort: true,align:'left'}
                ,{field:'created_at', title: '创建时间', sort: true,align:'left'}
                //,{field:'op', title: '操作',toolbar: '#barTar', width:150,align:'center'}
            ]],
            page: true,
            id: 'testReload'
        });
        table.on('tool(data_table)', function(obj){
            var data = obj.data;
            data.table = "goods";
            if(obj.event === 'del'){
                layer.confirm('确定删除吗？', function(index){
                    layer.close(index);
                    form.formDel(data,obj);
                });
            }
        });
        var $ = layui.$, active = {
            reload: function(){
                var name = $('#name');

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        name: name.val()
                    }
                }, 'data');
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
{/block}